package com.elf.zero.utils;

import android.app.Activity;
import android.os.Build;
import android.view.WindowManager;

/**
 * oppo 工具类
 * Created by Lidong on 2018/12/14.
 */
public class OppoUtils {

    public static boolean setStatusBarLightMode(Activity activity, boolean lightMode) {
        if (!RomUtils.isOppo()) {
            return false;
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            return false;
        }

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
            if ("V3.0".equals(RomUtils.getVersion())) {
                final int SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT = 0x00000010;
                activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                int vis = activity.getWindow().getDecorView().getSystemUiVisibility();
                if (lightMode) {
                    vis |= SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
                } else {
                    vis &= ~SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
                }
                activity.getWindow().getDecorView().setSystemUiVisibility(vis);
                return true;
            }
            return false;
        }

        return false;
    }
}
